package main.java.com.rmisorter.sorters;
import java.rmi.RemoteException;

public class BubbleSort extends SuperSort {
	private static final long serialVersionUID = 1L;

	public BubbleSort() throws RemoteException {
		super();
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Comparable[] sort(Comparable[] listToSort) {
		validateEmptyList(listToSort);
		//validateAlreadySortedList(listToSort);
		
	    int i, j;
	    Comparable temp;
	    for (j = 0; j < listToSort.length; j++) {
	       for (i = 1; i < listToSort.length - j; i++) {
	          if(listToSort[i-1].compareTo(listToSort[i]) > 0) {
	             temp = (Comparable) listToSort[i];
	             listToSort[i] = listToSort[i-1];
	             listToSort[i-1] = temp;
	          }
	       }
	    }
	    
	    return listToSort;	
	}
	
}
